package com.own.business.system.dictionary.entity.dto;

import com.own.business.system.dictionary.entity.bo.SystemDictionaryBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * SystemDictionaryDto
 *
 * @author chenxueli
 * @date 2023-06-21 09:41:42
 */
@Schema(title = "系统数据字典" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemDictionaryDto extends BaseDto<SystemDictionaryBo> {

    @Schema(title = "字典名称")
    private String name;

    @Schema(title = "唯一编号")
    private String code;

    @Schema(title = "图标")
    private String icon;

    @Schema(title = "顺序，默认数字越小约在前面")
    private Integer sortOrder;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public SystemDictionaryBo toBo(SystemDictionaryBo entity) {
        if (entity == null) {
            entity = new SystemDictionaryBo();
        }
        entity.setName(name);
        entity.setCode(code);
        entity.setIcon(icon);
        entity.setSortOrder(sortOrder);
        return super.toBo(entity);
    }

}
